#ifndef EDGEITEM_H
#define EDGEITEM_H
#include <QGraphicsLineItem>
#include <QPen>
#include <QBrush>
#include <QPainter>

#include <QDebug>

#include "nodeitem.h"

class NodeItem;

class EdgeItem:public QGraphicsLineItem
{
private:
    NodeItem *n1 ;
    NodeItem *n2 ;
public:
      enum { Type = UserType + 2 };
      EdgeItem(const QLineF &line);
      EdgeItem(NodeItem *from, NodeItem *to);



      void updatePosition();

      QPainterPath shape() const;
      QRectF boundingRect() const;
      void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
      int type() const {return Type;}

      NodeItem *getNode1();
      NodeItem *getNode2();

      NodeItem *getNodeOther(NodeItem *node);

      qreal getLength();

      void setEdgeColor(QColor c);
      void setEdgeWidth(int w);
      void setDefaultStyle();
private:
      QColor edgeColor ;
      int    edgeWidth ;
      QPen pen_def;
      QPen pen_current;


};

#endif // EDGEITEM_H
